/*
 * insertionSort.hpp
 *
 *  Created on: Sep 12, 2011
 *      Author: dgdiniz
 */

#ifndef INSERTIONSORT_HPP_
#define INSERTIONSORT_HPP_

#include "utility/utility.hpp"

template <typename T>
void insertionSort(T list[], const unsigned length)
{
	for (int j=1; j < length; j++)
		for (int i = j-1; i>=0 && list[i]>list[i+1]; i--)
			swap(list[i], list[i+1]);
}

template <typename T>
void insertionSortDec(T list[], const unsigned length)
{
	for (int j=1; j < length; j++)
		for (int i = j-1; i>=0 && list[i]<list[i+1]; i--)
			swap(list[i], list[i+1]);
}

#endif /* INSERTIONSORT_HPP_ */
